package www.wen.com.common.lib.data.repository

import kotlinx.coroutines.flow.Flow
import okhttp3.MultipartBody
import www.wen.com.common.lib.data.db.AppDbHelper
import www.wen.com.common.lib.data.entities.*
import www.wen.com.common.lib.data.network.ApiHelper

/**
 * @author WEN
 * @Description:
 * @date 2020/11/25 11:09
 */
interface AppDataManager : AppDbHelper, ApiHelper {

    fun loginOrRegisterFlow(type: String, requestRegisterBody: RequestRegisterBody): Flow<Result.Success<LoginInfo>>

    fun smsLoginFlow(requestRegisterBody: RequestRegisterBody): Flow<Result.Success<LoginInfo>>

    fun accessTokenFlow(code: String): Flow<Result.Success<WxEntity>>

    fun <T> loginOrRegisterByTokenFlow(
            type: String,
            body: RequestLoginOrRegisterByToken,
            emitObject: (loginInfo: (EmptyEntity)) -> T,
    ): Flow<T>

    fun resetPasswordFlow(body: RequestBodyParameter): Flow<Result.Success<UseInfoEntity>>

    fun requestUserInfoByIdFlow(id:String): Flow<Result.Success<UseInfoEntity>>

    fun uploadOssFileFlow(
            partMap: Map<String, okhttp3.RequestBody>,
            vararg file: MultipartBody.Part,
    ): Flow<Result.Success<UpOssFileEntity>>

    fun updateServerInfoFlow(serverId: String, body: RequestBodyParameter): Flow<Result.Success<ServerUpdateInfoEntity>>

    fun createServerFlow(body: RequestBodyParameter): Flow<Result.Success<ServerEntity>>

    fun searchUserByNickNameFlow(nickName: String): Flow<Result.Success<UseInfoEntity>>

    fun getServerMemberListFlow(serverId: String, nickName: String?, page: Int, size: Int): Flow<Result.Success<ServiceMemberListEntity>>

    fun requestUsersOnlineStatusFlow(accids: Array<String>): Flow<Result.Success<List<UseInfoEntity>>>

    fun requestServerListFlow(
            serverIdOrName: String?,
            recommendFlag: String?,
            page: Int?,
            size: Int?,
    ): Flow<Result.Success<ServerListEntity>>

    fun getServerChannelTopMsgListFlow(teamId: String): Flow<Result.Success<TopMsgEntity>>

    fun requestChannelIdFlow(channelId: Long): Flow<Result.Success<ChannelInfo>>

    fun serverGroupListFlow(serverId: String): Flow<Result.Success<ServerGroupEntity>>

    fun groupSortFlow(body: List<RequestBodyParameter>): Flow<Result.Success<List<ChannelBatchEntity>>>

    fun deleteChannelFlow(channelId: Long): Flow<Result.Success<String>>

    fun patchChannelFlow(channelId: Long, body: RequestBodyParameter): Flow<Result.Success<ChannelInfo>>

    fun userInfoFlow(body: RequestBodyParameter): Flow<Result.Success<UseInfoEntity>>

    fun registerByTokenFlow(body: RequestLoginOrRegisterByToken): Flow<Result.Success<LoginInfo>>

}